<template>
  <div class="biz-task">
    <div class="biz-task-content">
      <div class="wrap">
        <img
          class="icon"
          :src="biz_task"
          alt=""
        />
        <div class="biz-task-content-view-group">
          <div class="biz-form-view-row">
            <div class="biz-form-view-row-content">
              {{ msgInfo.messageContent.taskTypeName }}
            </div>
          </div>
          <div class="biz-form-view-row">
            <label>{{$t('common.form.type.taskNo')}}</label><span>:</span>
            <div class="biz-form-view-row-content">
              {{ msgInfo.messageContent.taskNo }}
            </div>
          </div>
          <div class="biz-form-view-row">
            <label>{{$t('common.base.customer')}}</label><span>:</span>
            <div class="biz-form-view-row-content">
              {{ msgInfo.messageContent.customerName }}
            </div>
          </div>
        </div>
      </div>
      <div class="biz-task-content-send">
        <span @click="sendMessage">{{$t('common.notification.sendTaskMessage')}}</span>
      </div>
    </div>
  </div>
</template>

<script>
/** api */
import { sendBizMessage } from '@src/modules/system/frame/component/InternalCoordination/chat/components/send.js';
import { getOssUrl } from '@src/util/assets'
const biz_task = getOssUrl('/im/biz_task.jpg')

export default {
  name: 'biz-task',
  inject: ['chatParams', 'delMsg'],
  props: {
    msgInfo: {
      type: Object,
      default: () => ({}),
    },
    idx: {
      type: Number,
    },
  },
  data() {
    return {
      biz_task
    };
  },
  methods: {
    async sendMessage() {
      try {
        const params = {
          messageType: 'task',
          chatType: 1,
          chatUuid: this.chatParams().chatUuid,
          messageContent: this.msgInfo.messageContent,
        };
        let messageInfo = await sendBizMessage(params);
        this.$eventBus.$emit('addMsg_insideIM', messageInfo);
        this.delMsg(this.idx);
      } catch (err) {
        console.error(err);
      }
    },
  },
};
</script>

<style scoped lang='scss'>
.biz-task {
  display: flex;
  justify-content: center;

  &-content {
    width: 300px;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    box-sizing: border-box;
    padding: 10px 15px 0;
    .wrap {
      display: flex;
      .icon {
        width: 40px;
        height: 40px;
        border-radius: 4px;
        margin-right: 12px;
      }
      .biz-task-content-view-group {
        flex: 1;
        .biz-form-view-row {
          display: flex;
          justify-content: flex-start;
          align-items: center;
          color: #262626;
          margin-bottom: 5px;
          label {
            color: #595959;
            flex-shrink: 0;
            line-height: 20px;
            width: 60px;
            text-align: justify;
            text-align-last: justify;
          }
          span {
            margin: 0 10px 0 0;
          }
          .biz-form-view-row-content {
            color: #262626;
            flex: 1;
            line-height: 20px;
            overflow-x: hidden;
            overflow-y: hidden;
            word-break: break-word;
          }
        }
      }
    }

    &-send {
      text-align: center;
      width: 100%;
      border-top: 1px solid #e8e8e8;
      height: 30px;
      display: flex;
      justify-content: center;
      align-items: center;
      color: $color-primary-light-6;
      font-size: 12px;
      span {
        cursor: pointer;
      }
    }
  }
}
</style>